]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
portalHelper: Don't fail to load because of TLS errors
authorBastien Nocera <hadess@hadess.net>
Mon, 13 Feb 2017 09:44:01 +0000 (10:44 +0100)
committerBastien Nocera <hadess@hadess.net>
Wed, 15 Feb 2017 13:30:07 +0000 (14:30 +0100)
Accept self-signed and expired certificates as if we errored out, we
couldn't access the network at all. Consider this insecure though.

https://bugzilla.gnome.org/show_bug.cgi?id=778253

js/portalHelper/main.js

index a32213706fc46c89adcc376c841b0ad807aecabc..84eed5754221bc87f0a48ba1f1d88c78044e68f0 100644 (file)
@@ -146,13 +146,14 @@ const PortalWindow = new Lang.Class({
 
         let dataManager = new WebKit.WebsiteDataManager({ base_data_directory: cacheDir,
                                                           base_cache_directory: cacheDir });
-        let webContext = new WebKit.WebContext({ website_data_manager: dataManager });
-        webContext.set_cache_model(WebKit.CacheModel.DOCUMENT_VIEWER);
+        this._webContext = new WebKit.WebContext({ website_data_manager: dataManager });
+        this._webContext.set_cache_model(WebKit.CacheModel.DOCUMENT_VIEWER);
 
-        this._webView = WebKit.WebView.new_with_context(webContext);
+        this._webView = WebKit.WebView.new_with_context(this._webContext);
         this._webView.connect('decide-policy', Lang.bind(this, this._onDecidePolicy));
         this._webView.connect('load-changed', Lang.bind(this, this._onLoadChanged));
         this._webView.connect('insecure-content-detected', Lang.bind(this, this._onInsecureContentDetected));
+        this._webView.connect('load-failed-with-tls-errors', Lang.bind(this, this._onLoadFailedWithTlsErrors));
         this._webView.load_uri(url);
         this._webView.connect('notify::uri', Lang.bind(this, this._syncUri));
         this._syncUri();
@@ -210,6 +211,14 @@ const PortalWindow = new Lang.Class({
         this._headerBar.setSecurityIcon(PortalHelperSecurityLevel.INSECURE);
     },
 
+    _onLoadFailedWithTlsErrors: function (view, failingURI, certificate, errors) {
+        this._headerBar.setSecurityIcon(PortalHelperSecurityLevel.INSECURE);
+        let uri = new Soup.URI(failingURI);
+        this._webContext.allow_tls_certificate_for_host(certificate, uri.get_host());
+        this._webView.load_uri(failingURI);
+        return true;
+    },
+
     _onDecidePolicy: function(view, decision, type) {
         if (type == WebKit.PolicyDecisionType.NEW_WINDOW_ACTION) {
             decision.ignore();